<template>
  <div class="recommend">
      <!-- 轮播图 -->
      <van-swipe  :autoplay="1000">
        <van-swipe-item v-for="item in recommends" :key="item.id">
          <van-image :src="item.picUrl" />
        </van-swipe-item>
      </van-swipe>
  </div>
</template>

<script>
import { getRecommend } from '../../api/recommend'
import { ERR_OK } from '../../api/config'
// 导入轮播图组件
// import Slider from '../../base/slider/slider'
export default {
  data () {
    return {
      // 轮播图所需的数据
      recommends: []
    }
  },
  created () {
    this._getRecommend()
  },
  methods: {
    _getRecommend () {
      getRecommend().then(res => {
        if (res.code === ERR_OK) {
          this.recommends = res.data.slider
          console.log(this.recommends)
        }
      })
    }
  },
  components: {
    // Slider
  }
}
</script>

<style lang="stylus">
.recommend {
    .swipe {
      img {
        display: block;
        width: 100%;
        height: 240px;
      }
    }
}
</style>
